<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function counter() {
        let i = 1
        function add () {
            return i++
        }
        return add
    }

    const result = counter()
    console.log(result())   // 1
    console.log(result())   // 2
    console.log(result())   // 3

</script>
</body>
</html>
